/**
 * Created by zhuyongjie on 2017/12/13.
 */
var tableId = "dataGrid";
var url = path + "/flow/showRole";
var queryParams = new Object();
$(function () {
    var grid = $("#" + tableId);
    initGrid(grid);
})

function saveROle(){
    var rows = $('#' + tableId).datagrid('getSelections');
    if (rows.length == 0) {
        $.alert("pick", "info", "角色");
        return;
    }
    var roleCodes = new Array();
    var roleNames = new Array();
    roleCodes.push("R(")
    roleNames.push("角色(")
    $.each(rows,function (index,row) {
        var roleCode = row.ROLE_CODE;
        var roleName = row.ROLE_NAME;
        roleCodes.push(roleCode);
        roleCodes.push(",");
        roleNames.push(roleName);
        roleNames.push(",");

    });
    roleCodes.splice(roleCodes.length - 1,1);
    roleNames.splice(roleNames.length - 1,1);

    roleCodes.push(")");
    roleNames.push(")");


    setGlobalVariable("selectedRole",roleCodes.join(""));
    setGlobalVariable("selectedRoleName",roleNames.join(""));

   setTimeout("closeLayer()",100);//设置延时，防止IE下出现异常
}

/**
 * 初始化表格
 * @param grid
 */
function initGrid(grid) {
    var toolbar = '';
    initPageGridWithCheck(grid, queryParams, url, columns, toolbar);
    getPage(grid, queryParams, url);

}


var columns = [
    {
        field: "ROLE_NAME",
        title: "角色名称",
        align: "center",
        halign: "center",
        sortable: false,
        resizable: true,
        width: 150
    },
    {
        field: "ROLE_CODE",
        title: "角色编码",
        align: "center",
        halign: "center",
        sortable: false,
        resizable: true,
        width: 120
    }
];
